import React, { FC, useRef } from 'react'
const UseRefDemo: FC = () => {
  const inputRef = useRef<HTMLInputElement>(null)
  const selectInput = () => {
    const inputElem = inputRef.current
    inputElem?.select()
    console.log(inputElem)
  }
  return (
    <div>
      <input type="text" defaultValue="hello world" ref={inputRef} />
      <button onClick={selectInput}>选中input</button>
    </div>
  )
}
export default UseRefDemo
